<body>
    <input type="text">
    <ul></ul>
    <script src="ajax-promise.js"></script>
    <script>
        let inpObj = document.querySelector('input');
        let timer = null;
        inpObj.oninput = function () {
            // console.log(1)
            if (timer) return
            timer = setTimeout(() => {

                get(`https://www.baidu.com/sugrec`,
                    // `prod=pc&wd=${this.value}`,
                    { prod: 'pc', wd: this.value },
                    'json',
                    {}
                )
                    .then(res => {
                            console.log(res)
                            document.querySelector('ul').innerText = "";
                            if (!res.g) return 0;
                            res.g.forEach((item, i) => {
                                let liObj = document.createElement('li');
                                liObj.innerText = item.q;
                                document.querySelector('ul').appendChild(liObj);
                            })
                        }
                    )
                    .catch(
                        err => { }
                    )

            }, 1000);
        }
    </script>
</body>